package main

import "fmt"

/**
map定义:
map2 := make(map[int]string)
var map3 map[int]string = map[int]string{}

map赋值:
map1[key]=value

遍历:
	for k, v := range map1 {
		fmt.Println(k, v)
	}

map通过key取值:
	v, state := map3[1]
	if (state == true) {
		fmt.Println(v)
	} else {
		fmt.Println(1, "不存在")
	}
map删除key所在元素:
func delete(m map[Type]Type1, key Type)

 */

func main() {
	var map1 map[int]string
	map1 = make(map[int]string, 5)
	//make创建map
	map2 := make(map[int]string)

	for i := 0; i < 10; i++ {
		map1[i] = "hi"
		map1[i] = "mike"
	}
	fmt.Println(len(map1))
	fmt.Println(len(map2))

	//map无序
	for k, v := range map1 {
		fmt.Println(k, v)
	}
	var map3 map[int]string = map[int]string{}
	fmt.Println("map3")
	map3[1] = "1"
	map3[3] = "3"
	map3[2] = "2"
	fmt.Println(map3)

	v, state := map3[6]
	if (state == true) {
		fmt.Println(v)
	} else {
		fmt.Println(6, "不存在")
	}
	v2, state2 := map3[2]
	if (state2 == true) {
		fmt.Println(v2)
	} else {
		fmt.Println(2, "不存在")
	}
	//
	fmt.Println("map delete")
	delete(map3, 1)
	fmt.Println(map3)

}
